﻿# Once done, this will define
#
# WOLFMQTT_INCLUDE_DIR - theWOLFMQTT include directory
# WOLFMQTT_LIBRARY_DIR - theWOLFMQTT library directory
# WOLFMQTT_LIBS - link these to useWOLFMQTT
#
#  ......

MACRO(load_wolfmqtt os arch)
    MESSAGE(INFO "--------------------------------")
    SET(3RDPARTY_DIR ${PROJECT_SOURCE_DIR}/3rdparty/target/${${os}}_${${arch}})
    MESSAGE(STATUS "3RDPARTY_DIR: ${3RDPARTY_DIR}")
    #FIND_FILE(WOLFMQTT_INCLUDE_DIR include ${3RDPARTY_DIR} NO_DEFAULT_PATH)
    #FIND_FILE(WOLFMQTT_LIBRARY_DIR lib ${3RDPARTY_DIR} NO_DEFAULT_PATH)
    SET(WOLFMQTT_INCLUDE_DIR ${3RDPARTY_DIR}/include)
    SET(WOLFMQTT_LIBRARY_DIR ${3RDPARTY_DIR}/lib/wolfmqtt)

    IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
        SET(WOLFMQTT_LIBS wolfmqtt )
    ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
       SET(WOLFMQTT_LIBS wolfmqtt)
    ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux")

    IF(WOLFMQTT_INCLUDE_DIR)
        #SET(WOLFMQTT_LIBRARY_DIR "${WOLFMQTT_LIBRARY_DIR}/wolfmqtt")
        #SET(WOLFMQTT_LIBS "${WOLFMQTT_LIBRARY_DIR}/libwolfmqtt.a")
        #SET(WOLFMQTT_LIBS "${WOLFMQTT_LIBRARY_DIR}/libWOLFMQTT.so")
        MESSAGE(STATUS "WOLFMQTT_INCLUDE_DIR : ${WOLFMQTT_INCLUDE_DIR}")
        MESSAGE(STATUS "WOLFMQTT_LIBRARY_DIR : ${WOLFMQTT_LIBRARY_DIR}")
        MESSAGE(STATUS "WOLFMQTT_LIBS : ${WOLFMQTT_LIBS}")
    ELSE()
        MESSAGE(FATAL_ERROR "libWOLFMQTT not found!")
    ENDIF()
ENDMACRO()
